package com.guguskins.back.controller;

import com.guguskins.back.entity.vo.ResultVo;
import com.guguskins.back.utils.OSSUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @date 2021/5/14 10:46
 */
@RestController
@RequestMapping("/image")
public class ImageController {

    @PostMapping("/upload")
    public ResultVo upload(@RequestParam("image") MultipartFile image,
                           @RequestParam(value = "dir", required = false, defaultValue = "") String dir,
                           @RequestParam(value = "flag", required = false, defaultValue  = "true") boolean flag) {
        String url = OSSUtil.uploadMultipartFile(image, dir, flag);
        return ResultVo.success((Object) url);
    }

    /*@PostMapping("/uploadByName")
    public ResultVo uploadByName() {

    }*/
}
